package cn.rkylin.oms.sysreturn.dao.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.alibaba.fastjson.JSON;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.sysreturn.dao.ISysReturnSkuDAO;
import cn.rkylin.oms.sysreturn.domain.SysReturn;
import cn.rkylin.oms.sysreturn.domain.SysReturnSku;
import cn.rkylin.oms.sysreturn.vo.SysReturnVO;

/**
 * 类名:SysReturnSkuDAOImpl <br/>
 * 作用: 退货单明细数据访问类. <br/>
 * 创建原因:	 退货单明细数据库操作. <br/>
 * 创建时间:     2017年9月28日 下午8:17:57 <br/>
 * @author   zhanghao
 * @version  v1.0 
 */
@Repository("sysReturnSkuDAO")
public class SysReturnSkuDAOImpl implements ISysReturnSkuDAO {
    @Autowired
    IDataBaseFactory dao;

    String STATEMENT_INSERT_NOT_EXISTS = "insertNotExistsSysReturnSku";
    String STATEMENT_INSERT_SELECTIVE = "insertSelectiveSysReturnSku";
    String STATEMENT_UPDATE_SELECTIVE_BY_AUTO_SYSRETURN = "updateSelectivebyAutoSysReturn";
    String STATEMENT_DELETE_BY_SYSRETURNSKUID = "deletebySysReturnSkuId";
    /**
     * TODO [简要描述复写方法的内容].
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnSkuDAO#deleteByPrimaryKey(java.lang.String)
     */
    @Override
    public int deleteByPrimaryKey(String refundSkuId) {
        
        // TODO Auto-generated method stub
        return 0;
    }

    /**
     * 插入退货单明细.
     * @throws Exception 
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnSkuDAO#insert(cn.rkylin.oms.sysreturn.domain.SysReturnSku)
     */
    @Override
    public int insert(SysReturnSku record) throws Exception {
        return dao.insert(STATEMENT_INSERT_SELECTIVE, record);
    }

    /**
     * TODO [简要描述复写方法的内容].
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnSkuDAO#insertSelective(cn.rkylin.oms.sysreturn.domain.SysReturnSku)
     */
    @Override
    public int insertSelective(SysReturnSku record) {
        
        // TODO Auto-generated method stub
        return 0;
    }

    /**
     * TODO [简要描述复写方法的内容].
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnSkuDAO#selectByPrimaryKey(java.lang.String)
     */
    @Override
    public SysReturnSku selectByPrimaryKey(String refundSkuId) {
        
        // TODO Auto-generated method stub
        return null;
    }

    /**
     * TODO [简要描述复写方法的内容].
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnSkuDAO#updateByPrimaryKeySelective(cn.rkylin.oms.sysreturn.domain.SysReturnSku)
     */
    @Override
    public int updateByPrimaryKeySelective(SysReturnSku record) {
        
        // TODO Auto-generated method stub
        return 0;
    }

    /**
     * TODO [简要描述复写方法的内容].
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnSkuDAO#updateByPrimaryKey(cn.rkylin.oms.sysreturn.domain.SysReturnSku)
     */
    @Override
    public int updateByPrimaryKey(SysReturnSku record) {
        
        // TODO Auto-generated method stub
        return 0;
    }

    /**
     * 插入不存在的退货单明细.
     * @throws Exception 
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnSkuDAO#insertNotExistSku(cn.rkylin.oms.sysreturn.domain.SysReturnSku)
     */
    @Override
    public int insertNotExistSku(SysReturnSku sysReturnSku) throws Exception {
        return dao.insert(STATEMENT_INSERT_NOT_EXISTS, sysReturnSku);
    }

    /**
     * @throws Exception 
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnSkuDAO#deleteByAutoSysReturnID(java.lang.String)
     */
    @Override
    public int deleteByAutoSysReturnID(String returnId) throws Exception {
        SysReturnSku param = new SysReturnSku();
        param.setDeleted("y");
        param.setReturnId(returnId);
        return dao.update(STATEMENT_UPDATE_SELECTIVE_BY_AUTO_SYSRETURN, param);
    }

    /**
     * deleteBySysReturnSkuID:根据自动退货单明细ID删除数据. <br/>
     *
     * @param returnSkuId
     * @return
     * @throws Exception
     * @author zhanghao
     */
    @Override
    public int deleteBySysReturnSkuID(String returnSkuId) throws Exception {
        return dao.update(STATEMENT_DELETE_BY_SYSRETURNSKUID, returnSkuId);
    }

}

